package com.atguigu.ssyx.common.auth;

import com.atguigu.ssyx.vo.user.UserLoginVo;

/**
 * Created with IntelliJ IDEA.
 * ClassName: AuthContextHolder
 * Package: com.atguigu.ssyx.common.auth
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-10-02
 * Time: 18:13
 */

//使用ThreadLocal 现成变量
public class AuthContextHolder {

    //用户id
    private static ThreadLocal<Long> userId = new ThreadLocal<>();

    //用户仓库id
    private static ThreadLocal<Long> wareId = new ThreadLocal<>();

    //用户信息对象
    private static ThreadLocal<UserLoginVo> userLoginVo = new ThreadLocal<>();

    //userId操作
    public static void setUserId(Long _userId){
        userId.set(_userId);
    }
    public static Long getUserId(){
        return userId.get();
    }


    public static Long getWareId(){
        return wareId.get();
    }

    public static void setWareId(Long _wareId){
        wareId.set(_wareId);
    }

    public static UserLoginVo getUserLoginVo() {
        return userLoginVo.get();
    }

    public static void setUserLoginVo(UserLoginVo _userLoginVo) {
        userLoginVo.set(_userLoginVo);
    }

}
